package thread_01;

import java.util.Scanner;

public class Demo25 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(() ->{
            synchronized (locker){
                System.out.println("t1等待前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1等待后");
            }
        });

        Thread t2 = new Thread(() ->{
            Scanner scanner = new Scanner(System.in);
            synchronized (locker){
                System.out.println("t2通知前");
//                卡在这
                scanner.next();
                locker.notify();
                System.out.println("t2通知后");
            }
        });

        t1.start();
        t2.start();
    }
}
